package com.mcp.converter.domain.rule.compatibility.datatype;

import com.mcp.converter.domain.checker.IncompatibilityDetail;
import com.mcp.converter.shared.response.sql.SQLElement;
import com.mcp.converter.domain.rule.compatibility.AbstractDataTypeRule;

/**
 * LONG RAW数据类型兼容性规则
 * OceanBase不支持LONG RAW数据类型
 */
public class LongRawDataTypeRule extends AbstractDataTypeRule {
    
    private static final String RULE_ID = "DT003";
    private static final String RULE_NAME = "LONG RAW数据类型不兼容";
    private static final String RULE_DESCRIPTION = "OceanBase不支持LONG RAW数据类型，建议使用BLOB替代";
    
    public LongRawDataTypeRule() {
        super(RULE_ID, RULE_NAME, RULE_DESCRIPTION);
        setIncompatibilityDetail(
            "OceanBase不支持LONG RAW数据类型，该类型在Oracle中已被废弃",
            "使用LONG RAW数据类型的SQL语句在OceanBase中将执行失败",
            "建议使用BLOB数据类型替代LONG RAW数据类型",
            IncompatibilityDetail.Severity.CRITICAL
        );
    }
    
    @Override
    public boolean matches(Object target) {
        if (target instanceof SQLElement) {
            SQLElement element = (SQLElement) target;
            if (isDataTypeElement(element)) {
                String dataTypeName = element.getName().toUpperCase();
                return "LONG RAW".equals(dataTypeName);
            }
        }
        return false;
    }
}
